package cn.itsource.pethome.dictionary.service.impl;

import cn.itsource.pethome.basic.service.impl.BaseServiceImpl;
import cn.itsource.pethome.dictionary.domain.Systemdictionarytype;
import cn.itsource.pethome.dictionary.mapper.DctionaryMapper;
import cn.itsource.pethome.dictionary.mapper.DictionarydetailMapper;
import cn.itsource.pethome.dictionary.service.IDctionaryService;
import cn.itsource.pethome.org.domain.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class DctionaryServiceImpl extends BaseServiceImpl<Systemdictionarytype> implements IDctionaryService{
    @Autowired
    DctionaryMapper dctionaryMapper;
    @Autowired
    DictionarydetailMapper dictionarydetailMapper;

    @Override
    @Transactional
    public void save(Systemdictionarytype systemdictionarytype) {
        if (systemdictionarytype.getId() == null) {
            dctionaryMapper.save(systemdictionarytype);
        }else{
            this.update(systemdictionarytype);
        }


    }

    @Override
    public List<Systemdictionarytype> findtypesId() {
        return dctionaryMapper.findtypesId();
    }
    @Override
    @Transactional
    public void delete(Long id) {
        dictionarydetailMapper.deletBytype(id);
        dctionaryMapper.delete(id);
    }
}
